package com.photo.tagger;

import android.app.Activity;
import android.media.ExifInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.Toast;

public class TestExif extends Activity implements OnClickListener, OnTouchListener{

	ExifInterface exif;
	TagEdit editTag;
	//ArrayList<TagEdit> tagList;
	FrameLayout lay;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.second);
		Log.i("exif", "start aindhi");
		editTag=new TagEdit(this,10,10);
		//tagList=new ArrayList<TagEdit>();
		
		lay=(FrameLayout) findViewById(R.id.second_linear);
		lay.addView(editTag);
		
		lay.setOnTouchListener(this);
		prepareTags();
		addListeners();
		/*
		 * ImageButton ib = new ImageButton(this);
		 * ib.setImageResource(R.drawable.remove_button);
		 * ib.setBackgroundColor(Color.TRANSPARENT); ImageButton ib2 = new
		 * ImageButton(this); ib2.setImageResource(R.drawable.remove_button);
		 * 
		 * lay.addView(ib); lay.addView(ib2, 200, 300);
		 * ib.setOnClickListener(this);
		 */
		Log.i("exif", "content view aipoindhi");
		
		/*
		try {
			String imagepath;
			imagepath = Environment.getExternalStorageDirectory().getPath();
			imagepath += "H.JPG";
			exif = new ExifInterface(imagepath);
			Log.i("exif", "vachi sachindhi..");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			Log.i("exif", "Biscuit");
			e.printStackTrace();
		}
		String h = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
		Log.i("exif", h + "  vachindhi mari");
		exif.setAttribute("taptag", "fdaslfklsdfjl");
		exif.setAttribute("taptag1", "lfklsdfjl");
		try {
			exif.saveAttributes();
		} catch (IOException e) {
			Log.i("exif", "Biscuit aindhi rooooo");
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/

	}

	public void prepareTags()
	{
		editTag.setID(1);
	}
	public void addListeners()
	{
		editTag.getRemoveButton().setOnClickListener(this);
		editTag.getTagArea().getTagSquare().setOnClickListener(this);
	}
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		if (true) {
			;
		}
		Toast.makeText(this, "inkem peekale", Toast.LENGTH_SHORT);
		lay.removeView(editTag);
		lay.invalidate();
		lay.refreshDrawableState();
	}

	public boolean onTouch(View arg0, MotionEvent arg1) {
		// TODO Auto-generated method stub
		Toast.makeText(this, "touch chesav "+(int)arg1.getX()+" , "+ (int)arg1.getY(), Toast.LENGTH_SHORT).show();
		TagEdit n=new TagEdit(this,10,10);
		AbsoluteLayout abs=new AbsoluteLayout(this);
		abs.addView(n,  (int)arg1.getX(), (int)arg1.getY());
		lay.addView(abs);
		lay.invalidate();
		lay.refreshDrawableState();

		
		
		return false;
	}

}
